from django.db import models

class Species(models.Model):
    name = models.CharField("Species", max_length=50)
    slug = models.SlugField("Slug",max_length=50, unique=True, blank=True, help_text='Unique value for product page URL, created from name.')
    description = models.TextField("Description")
    image = models.ImageField(upload_to='species_image', blank=True) 
    is_active = models.BooleanField("Activated",default=True, help_text='This field lets us turn the species on or off.')
    
    class Meta:
        db_table = 'species'
        verbose_name = ("Species")
        verbose_name_plural = ("Species")
        
    def __unicode__(self):
        return self.name
    
    
class Subspecies(models.Model):
    species = models.ForeignKey(Species)
    name = models.CharField("Subspecies", max_length=50)
    slug = models.SlugField("Slug",max_length=50, unique=True, blank=True, help_text='Unique value for product page URL, created from name.')
    description = models.TextField("Description")
    image = models.ImageField(upload_to='subspecies_image', blank=True) 
    is_active = models.BooleanField("Activated",default=True, help_text='This field lets us turn the subspecies on or off.')
    
    class Meta:
        db_table = 'subspecies'
        verbose_name = ("Subspecies")
        verbose_name_plural = ("Subspecies")
        
    def __unicode__(self):
        return self.name
    
    
class Bird(models.Model):
    specie = models.ForeignKey(Species, db_column="specie")
    subspecie = models.ForeignKey(Subspecies,db_column="subspecie", blank=True, null=True)
    mutation = models.CharField("Mutation", max_length=50)
    slug = models.SlugField("Slug",max_length=50, unique=True, blank=True, help_text='Unique value for product page URL, created from name.')
    image = models.ImageField(upload_to='bird_image', blank=True)    
    price = models.DecimalField("Price", max_digits=9, decimal_places=2)
    stock = models.IntegerField("Stock")
    details = models.TextField("Details")
    is_active = models.BooleanField("Activated",default=True, help_text='This field lets us turn the subspecies on or off.')
    is_bestseller = models.BooleanField("Bestseller", default=False)
    is_featured = models.BooleanField("Featured", default=False)
       
    class Meta:
        db_table = 'birds'
        verbose_name = ("Bird")
        verbose_name_plural = ("Birds")
        
    def __unicode__(self):
        return self.mutation